/************************************************************************************************/
/*Lab 3: AssemblerClasses.hh									*/
/*												*/
/*Description: This header file declares the "AssemblerData", the "AssemblyCommands", and	*/
/*	       the "Comments" classes and commands for those classes that will be used for an 	*/
/*	       assembler.									*/
/*												*/
/*Modification Log:										*/
/*												*/
/*		2012/03/21 - Removed the "AssemblyCommands" class and renamed the "Genral" class*/
/*			     to "Comments" and the variable "gen" to "com".  Also created a new */
/*			     "General" class that will store vectors of tokens.  I reorganized 	*/
/*			     the the "AssemblyData" to, adjusting it to the new classes.  It now*/
/*			     stores a vector of .text instructions,  a vector of .ktext		*/
/*			     instructions, a vector of .data instructions, and a vector of	*/
/*			     .kdata instructions.  It also contains a vector of comments and a	*/
/*			     a vector of errors (strings).  I've also removed the functions that*/
/*			     where inappropriate and added some new functions for the new	*/
/*			     structure. (Samuel Thacker)					*/
/*		2012/03/12 - Added position field "pos" and associated commands for it.		*/
/*			     (Samuel Thacker)							*/
/*		2012/03/07 - Adjusted the "General" class and the "AssemblyCommands" class to	*/
/*			     not need destructors and made them store just a plain vector or	*/
/*			     string instead of a pointer to one.  Also created special return	*/
/*			     funtions to make accessing much easier then it was before. The	*/
/*			     section with these commands is called "Special Return Commands" and*/
/*			     will make it easier to access information deep in the classes.	*/
/*			     (Samuel Thacker)							*/
/*		2012/02/28 - Rewrote some of the classes and made it so "Directives" takes a	*/
/*			     vector of strings instead of a string. (Samuel Thacker)		*/
/*		2012/02/17 - Combined the "Comments", "Directives", and "Labels" classes into	*/
/*			     one general class, called "General". Changed the "AssemblerData"	*/
/*			     class to contain a vector of strings instead of 4 specific strings,*/
/*			     and adapted to the funtions related to it.  Changed how "errors"	*/
/*			     are stored from a vector of "Errors" classes, to a vector of	*/
/*			     strings. (Samuel Thacker)						*/
/*		2012/02/15 - Separated the "AssemblerData" class into a operation code,		*/
/*			     directives, and labels. (Samuel Thacker				*/
/*		2012/02/14 - Made this file a little more consistant in the way it is formatted.*/
/*			     Modified the return string functions to return strings instead of	*/
/*			     pointers.  Declared Length, Append commands, and one special	*/
/*			     command (tests if vector "error" is empty) for the "AssemblerData" */
/*			     class. --Note, may want to seperate directives and labels into	*/
/*			     their own separate vectors and classes.-- (Samuel Thacker)		*/
/*		2012/02/13 - Added "Errors" class and modified all vector and string variables	*/
/*			     to be pointers. (Samuel Thacker)					*/
/*		2012/02/10 - Did some slight modifications to the code to fix some potential	*/
/*			     bugs, renamed the file from "AssemblerData.h" to			*/
/*			     "AssemblerClasses.h", added comments to the end of each class	*/
/*			     declaration to help organize the file, and made some modifications	*/
/*			     to this comments section. (Samuel Thacker)				*/
/*		2012/02/09 - Creations of this header file with declarations of the 		*/
/*			     AssemberData, the AssemblyCommands, and the Comments classes,	*/
/*			     construtors and destructors for those classes, and some return	*/
/*			     commands for those structures. (Samuel Thacker)			*/
/*												*/
/*               ----Please report any modifications made to this file please----               */
/************************************************************************************************/

#ifndef ASSEMBLERCLASSES_HH
#define ASSEMBLERCLASSES_HH

#include <iostream>
#include <vector>
#include <string>
#include "tokens.hh"

using namespace std;

class AssemblerData;
class Comments;
class General;
class Tokens;
class TokensHeader;

class AssemblerData //Stores a list of assembly commands, a list of comments, and a list of data.
	{
	vector<General> * text; //Where the ".text" instructions are stored.
	vector<General> * ktext; //Where the ".ktext" instructions are stored.
	vector<General> * data; //Where the ".data" instructions are stored.
	vector<General> * kdata; //Where the ".kdata" instructions are stored.
	vector<Comments> * com; //Where the comments are stored.
	vector<unsigned int> * mc_data; //Where the machine code data will be stored.
	vector<string> * errors; //Where the errors that are encountered will be stored.

	public:
		/* Constructor and Destructor */
		AssemblerData();
		~AssemblerData();

		/* Return Commands */
		vector<General> * ret_text(); //Returns "text" (pointer)
		vector<General> * ret_ktext(); //Returns "ktext" (pointer)
		vector<General> * ret_data(); //Returns "data" (pointer)
		vector<General> * ret_kdata(); //Returns "kdata" (pointer)
		vector<Comments> * ret_com(); //Returns "com" (pointer)
		vector<unsigned int> * ret_mcData(); //Returns "mc_data" (pointer)
		vector<string> * ret_err(); //Returns "errors" (pointer)

		/* Special Return Commands */

		// text //
		vector<string> ret_text(unsigned int); //Returns the vector of tokens stored at index position "i"
		unsigned int ret_textLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_textFN(unsigned int); //Returns the file name stored at index position "i"

		// ktext //
		vector<string> ret_ktext(unsigned int); //Returns the vector of tokens vector stored at index position "i"
		unsigned int ret_ktextLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_ktextFN(unsigned int); //Returns the file name stored at index position "i"

		// data //
		vector<string> ret_data(unsigned int); //Returns the vector of tokens vector stored at index position "i"
		unsigned int ret_dataLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_dataFN(unsigned int); //Returns the file name stored at index position "i"

		// kdata //
		vector<string> ret_kdata(unsigned int); //Returns the vector of tokens stored at index position "i"
		unsigned int ret_kdataLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_kdataFN(unsigned int); //Returns the file name stored at index position "i"

		// Comments //
		string ret_com(unsigned int); //Returns the string stored at index position "i"
		unsigned int ret_comLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_comFN(unsigned int); //Returns the file name stored at index position "i"

		// MC Data //
		unsigned int ret_mcData(unsigned int); //Returns the code stored at index position "i"

		// Errors //
		string ret_err(unsigned int); //Returns the error stored at index position "i"

		/* Length Commands */
		unsigned int text_len(); //Returns the number of elements in "text"
		unsigned int ktext_len(); //Returns the number of elements in "ktext"
		unsigned int data_len(); //Returns the number of elements in "data"
		unsigned int kdata_len(); //Returns the number of elements in "kdata"
		unsigned int com_len(); //Returns the number of elements in "com"
		unsigned int mcData_len(); //Returns the number of elements in "mc_data"
		unsigned int err_len(); //Returns the number of elements in "errors"

		/* Append Commands */
		void text_append(vector<string>,unsigned int,string); //Appends to the vector "text"
		void ktext_append(vector<string>,unsigned int,string); //Appends to the vector "ktext"
		void data_append(vector<string>,unsigned int,string); //Appends to the vector "data"
		void kdata_append(vector<string>,unsigned int,string); //Appends to the vector "kdata"		
		void com_append(string,unsigned int,string); //Appends a comment to "com"
		void mcData_append(unsigned int); //Appends machine code (integer) to "mc_data"
		void err_append(string); //Appends an error (string) tor "errors"

		/* Special Commands */
		bool err_empty(); //Checks if vector "error" is empty. 1 if it is and 0 if otherwise.
	}; //END class AssemblerData

class Comments //Stores a comment and the line number it was on.
	{
	string com;
	unsigned int ln; //Line number the string is on.
	string fname; //file name

	public:
		/* Constructor */
		Comments(string,unsigned int,string);

		/* Return Commands */
		string ret_com(); //returns "com"
		string ret_fname(); //returns "fname"
		unsigned int ret_ln(); //returns "ln"
		unsigned int ret_pos(); //returns "pos"
	}; //END class Comments

class General //Stores ".text", .ktext", ".data", and ".kdata"
	{
	vector<string> Commands;
	unsigned int ln;
	string fn;

	public:
		/* Constructor */
		General(vector<string>,unsigned int,string);

		/* Return Commands */
		vector<string> ret_commands(); //Returns the vector of tokens stored in this class.
		unsigned int ret_ln();
		string ret_fn();
	};

#endif //ASSEMBLERCLASSES_HH
